package com.weitu.contractor.service.impl;

import com.weitu.contractor.entity.Trainee;
import com.weitu.contractor.entity.TraineeCriteria;
import com.weitu.contractor.mapper.TraineeMapper;
import com.weitu.contractor.service.TraineeService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class TraineeServiceImpl implements TraineeService {
    private final TraineeMapper traineeMapper;

    private static final Logger logger = LoggerFactory.getLogger(TraineeServiceImpl.class);

    @Autowired
    public TraineeServiceImpl(TraineeMapper traineeMapper) {
        this.traineeMapper = traineeMapper;
    }

    @Override
    public int countByCriteria(TraineeCriteria example) {
        int count = this.traineeMapper.countByCriteria(example);
        logger.debug("count: {}", count);
        return count;
    }

    @Override
    public Trainee selectByPrimaryKey(String id) {
        return this.traineeMapper.selectByPrimaryKey(id);
    }

    @Override
    public List<Trainee> selectByCriteria(TraineeCriteria example) {
        return this.traineeMapper.selectByCriteria(example);
    }

    @Override
    @Transactional
    public int deleteByPrimaryKey(String id) {
        return this.traineeMapper.deleteByPrimaryKey(id);
    }

    @Override
    @Transactional
    public int updateByPrimaryKeySelective(Trainee record) {
        return this.traineeMapper.updateByPrimaryKeySelective(record);
    }

    @Override
    @Transactional
    public int updateByCriteriaSelective(Trainee record, TraineeCriteria example) {
        return this.traineeMapper.updateByCriteriaSelective(record, example);
    }

    @Override
    @Transactional
    public int insertSelective(Trainee record) {
        return this.traineeMapper.insertSelective(record);
    }
}